package com.baidu.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.baidu.entity.Course;
import com.baidu.service.CourseService;

@Controller
public class QueryAllCourseController {
@Autowired
private CourseService courseService;
//��ѯȫ���꼶
@RequestMapping(value="QueryAllCourse")
public String QueryAllCourse(HttpServletRequest request) {
		List<Course> list2=courseService.getAll();
		request.setAttribute("list2", list2);
		if (list2.size()>0 && list2!=null) {
			return "/WEB-INF/view/other/courseList.jsp";
		}
	return "404.jsp";
}
//ɾ��
		@RequestMapping(value="DeleteCoure")
		@ResponseBody
		public String deleteCoure(Integer s_id) {
			int i = courseService.deletecoure(s_id);
			if (i>0) {
				return "success";
			}
			return "error";
		}
		//���
		@RequestMapping(value="addCourse")
		@ResponseBody
		public String addCourse(Course course) {
			int i = courseService.addcourse(course);
			if (i>0) {
				return "success";
			}
			return "error";
		}
}
